package com.erclab.internal.xpresso.util;

import java.util.HashMap;

import com.erclab.internal.xpresso.formelements.FormElement;
import com.erclab.internal.xpresso.forms.Form;

public class FormElementUtil {

	public static String getElementValue(Form theForm, HashMap keyValues, String columnName){
		for (int i = 0; i < theForm.getFormElements().size(); i++){
			FormElement fe = (FormElement)theForm.getFormElements().get(i);
			if (fe.getDestinationColumn() != null && columnName.equals(fe.getDestinationColumn())){
				return ((String[])keyValues.get("Field" + fe.getIdFormElement()))[0];
			}
		}
		return null;
	}
	
	public static Object getElementValue(Form theForm, String columnName){
		for (int i = 0; i < theForm.getFormElements().size(); i++){
			FormElement fe = (FormElement)theForm.getFormElements().get(i);
			if (fe.getDestinationColumn() != null && columnName.equals(fe.getDestinationColumn())){
				return fe.getUserValue();
			}
		}
		return null;
	}
	
	
}
